<?php
/**
 * @file functicons.php(皮肤调用的函数)
 * @package Japan-Style
 */
?>
<?php

remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');

if (function_exists('register_sidebar') )
	register_sidebar(array(
	    'name' => 'lsidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h4 class="sidebartitle">',
        'after_title' => '</h4>',
        ));
if (function_exists('register_sidebar') )
    register_sidebar(array(
	    'name' => 'rsidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h4 class="adsenseh">',
        'after_title' => '</h4>',
        ));



function src_simple_recent_comments($src_count = 8) {
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_approved, comment_type, comment_author_url,
SUBSTRING(comment_content,1,20) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND post_password = ''
ORDER BY comment_date_gmt DESC
LIMIT $src_count";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {
$output .= "<li><a href=\"" .strip_tags($comment->comment_author_url) . "\" title=\"" .strip_tags($comment->comment_author) . "\" target=\"_blank\">" .strip_tags($comment->comment_author) . "</a> &raquo; <a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "\" title=\"发表于《". $comment->post_title . "》\">" . strip_tags($comment->com_excerpt) ."</a></li>\n";
}
$output .= $post_HTML;
echo $output;
}

function inews_most_commented($no_posts = 8, $show_pass_post = false, $duration="") {
global $wpdb;
$request = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments";
$request .= " WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'";
if(!$show_pass_post) $request .= " AND post_password =''";
if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
}
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
$posts = $wpdb->get_results($request);
$output = '';
if ($posts) {
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$comment_count = $post->comment_count;
$permalink = get_permalink($post->ID);
$output .= "<li><a href=\"" . $permalink . "\" title=\"" . $post_title. "\">" . $post_title . "</a> (" . $comment_count .")</li>\n";
}
} else {
$output .= "\n<li>None found" ."</li>";
}
echo $output;
}

?>